package com.yunxi.service.dubboService.impl.hubToBiz;

import com.yunxi.core.util.WgrDate;
import com.yunxi.hubToBiz.pojo.PushOrderReceiptReqVO;
import com.yunxi.hubToBiz.pojo.PushOrderReceiptRespVO;
import com.yunxi.hubToBiz.service.PushOrderReceiptDubboService;
import com.yunxi.model.order.OrderReceipt;
import com.yunxi.service.dubboService.impl.OrderReceiptDubboServiceImpl;
import com.yunxi.service.localService.OrderReceiptService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;

import java.util.Date;

public class PushOrderReceiptDubboServiceImpl implements PushOrderReceiptDubboService {

    private final Logger logger = LoggerFactory.getLogger(OrderReceiptDubboServiceImpl.class);

    @Autowired
    @Qualifier(value = "orderReceiptServiceImpl")
    OrderReceiptService orderReceiptService;

    @Override
    public PushOrderReceiptRespVO pushOrderReceipt(PushOrderReceiptReqVO vo) {
        OrderReceipt orderReceipt = new OrderReceipt();
        orderReceipt.setPartnerCode(vo.getKunnr());
        orderReceipt.setOrderVehicleId(vo.getBstkd());
        orderReceipt.setPosnr(vo.getPosnr());
        orderReceipt.setVbeln(vo.getErpvbeln());
        orderReceipt.setVatno(vo.getVbeln());
        orderReceipt.setNetwr(vo.getNetwr());
        orderReceipt.setFkdat(vo.getFkdat());
        orderReceipt.setZuonr(vo.getZuonr());
        orderReceipt.setFkart(vo.getFkart());
        orderReceipt.setVkorg(vo.getVkorg());
        boolean isSuccess = orderReceiptService.save(orderReceipt);

        PushOrderReceiptRespVO respVO = new PushOrderReceiptRespVO();
        respVO.setZdate(WgrDate.date2Str(new Date(),"yyyy-MM-dd"));
        respVO.setZtime(WgrDate.date2Str(new Date(),"hh:mm:ss"));
        if(isSuccess){
            respVO.setZmess("处理成功！");
            respVO.setZstat("S");
        }else{
            respVO.setZmess("处理失败！");
            respVO.setZstat("E");
        }
        return respVO;
    }
}
